package com.landtool.lanbase.database.controller;

import com.landtool.lanbase.database.entity.TargetAreaManagement;
import com.landtool.lanbase.database.service.TargetAreaManagementService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TargetAreaManagement)表控制层
 *
 * @author lizhao
 * @since 2019-07-03 14:29:29
 */
@RestController
@RequestMapping("targetAreaManagement")
public class TargetAreaManagementController {
    /**
     * 服务对象
     */
    @Resource
    private TargetAreaManagementService targetAreaManagementService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("/info/{id}")
    public TargetAreaManagement selectOne(@PathVariable("id")  Integer id) {
        return this.targetAreaManagementService.queryById(id);
    }
    
    
    /**
     * 通过实体查询总数
     *
     * @param targetAreaManagement 实体
     * @return 对象列表
     */
    @GetMapping("/list")
    public List<TargetAreaManagement> list(TargetAreaManagement targetAreaManagement) {
        return this.targetAreaManagementService.queryAll(targetAreaManagement);
    }
    
    /**
     * 通过实体类增加数据
     *
     * @param targetAreaManagement 实体
     * @return 单条数据
     */
    @ResponseBody
    @PostMapping("/insert")
    public TargetAreaManagement insert(TargetAreaManagement targetAreaManagement){
        return  this.targetAreaManagementService.insert(targetAreaManagement);
    }
    
      /**
     * 通过实体类更新数据
     *
     * @param targetAreaManagement 实体
     * @return 单条数据
     */
    @ResponseBody
    @PostMapping("/update")
    public TargetAreaManagement update(TargetAreaManagement targetAreaManagement){

        return  this.targetAreaManagementService.update(targetAreaManagement);
    }

    /**
     * 通过主键删除单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ResponseBody
    @GetMapping("/delete/{id}")
    public boolean deleteById(@PathVariable("id") Integer id){
        return  this.targetAreaManagementService.deleteById(id);
    }

}